package com.heima.test2;

public class Test01 {
    public static void main(String[] args) {
        Dog dog = new Dog();
        feedAnimal(dog);
        Cat cat = new Cat();
        feedAnimal(cat);
        Pig pig = new Pig();
        feedAnimal(pig);

    }

    public static void feedAnimal(animal a) {
        a.drink();
        if (a instanceof Cat) {
            Cat a1 = (Cat) a;
            a1.catchMouse();
        }
    }
}
